import 'package:flutter/material.dart';

class SearchBar extends StatelessWidget {
  final EdgeInsetsGeometry? margin;
  final EdgeInsetsGeometry? padding;
  final String? hintText;
  final TextEditingController? controller;
  final ValueChanged<String>? onSubmitted;

  const SearchBar(
      {Key? key,
        this.margin,
        this.hintText,
        this.controller,
        this.onSubmitted,
        this.padding})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      padding: padding,
      child: Container(
        margin: margin,
        constraints: BoxConstraints(maxHeight: 44),
        child: TextField(
            autocorrect: false,
            controller: controller,
            textInputAction: TextInputAction.search,
            decoration: InputDecoration(
              fillColor: Colors.grey[150],
              contentPadding: EdgeInsets.symmetric(horizontal: 15),
              filled: true,
              enabledBorder: OutlineInputBorder(
                borderRadius: BorderRadius.all(Radius.circular(30)),
                borderSide: BorderSide(color: Colors.transparent),
              ),
              focusedBorder: OutlineInputBorder(
                borderRadius: BorderRadius.all(Radius.circular(30)),
                borderSide: BorderSide(color: Colors.transparent),
              ),
              hintText: hintText,
              prefixIcon: Icon(Icons.search),
            ),
            onSubmitted: onSubmitted),
      ),
    );
  }
}
